<div class="row"">
  <div class="col-md-2">
      <?php include(dirname(dirname(__FILE__)).'/sidebar.phtml');?>
  </div>
  <div class="col-md-10">
    <form class="form-inline task" action="/manage/user/index/" method = "GET">
      <div class="form-group">
        <label class="control-label">UID</label>
        <input class="form-control" name="uid" type="text" placeholder="UID" value="<?php if(!empty($params['uid'])): echo $params['uid']; endif;?>">
      </div>
      <div class="form-group">
        <label class="control-label">Mobile</label>
        <input class="form-control" name="mobile" type="text" placeholder="mobile" value="<?php if(!empty($params['mobile'])): echo $params['mobile']; endif;?>">
      </div>
      <div class="form-group largeBox">
        <label class="control-label">是否封禁</label>
        <div class="form-check checkGap">
          <label class="form-check-label">
            <input type="radio" name="ban" class="form-check-input" value="1" <?php if(!empty($params['ban'])): echo 'checked="checked"'; endif;?>/>
            是
          </label>
        </div>
        <div class="form-check">
          <label class="form-check-label">
            <input type="radio" name="ban" class="form-check-input" value="0" <?php if(empty($params['ban'])): echo 'checked="checked"'; endif;?>/>
            否
          </label>
        </div>
      </div>
      <div class="form-group largeBox">
        <label class="control-label">是否冻结</label>
        <div class="form-check checkGap">
          <label class="form-check-label">
            <input type="radio" name="frozen" class="form-check-input" value="1" <?php if(!empty($params['frozen'])): echo 'checked="checked"'; endif;?>/>
            是
          </label>
        </div>
        <div class="form-check">
          <label class="form-check-label">
            <input type="radio" name="frozen" class="form-check-input" value="0" <?php if(empty($params['frozen'])): echo 'checked="checked"'; endif;?>/>
            否
          </label>
        </div>
      </div>
      <div class="form-group">
        <label class="control-label">排序(倒序)</label>
        <select class="form-control" name="sort" style="width: 60px;">
          <option value="" <?php if(empty($params['sort']) || $params['sort']==''){ echo 'selected';} ?>>无</option>
          <option value="add_up" <?php if(!empty($params['sort']) && $params['sort']=='add_up'){ echo 'selected';} ?>>累计收入</option>
          <option value="invite_num" <?php if(!empty($params['sort']) && $params['sort']=='invite_num'){ echo 'selected';} ?>>邀请人数</option>
          <option value="invite_add_up" <?php if(!empty($params['sort']) && $params['sort']=='invite_add_up'){ echo 'selected';} ?>>邀请收入</option>
        </select>
      </div>
      <div class="form-group">
        <label class="control-label">地区</label>
        <input class="form-control" name="address" type="text" placeholder="地区" value="<?php if(!empty($params['address'])): echo $params['address']; endif;?>">(省+市,右模糊处理)
      </div>
      <div class="form-group">
        <label class="control-label">ip</label>
        <input class="form-control" name="ip" type="text" placeholder="ip" value="<?php if(!empty($params['ip'])): echo $params['ip']; endif;?>">
      </div>
      <div class="form-group">
        <label class="control-label">注册日期</label>
        <input class="form-control" name="start_date" type="text" autocomplete="off" id="startTime" value="<?php if(!empty($params['start_date'])):?><?php echo $params['start_date'];?> <?php endif;?>">
        至
        <input class="form-control" name="end_date" type="text" autocomplete="off" id="endTime" value="<?php if(!empty($params['end_date'])):?><?php echo $params['end_date'];?> <?php endif;?>">
      </div>
      <button type="submit" class="btn btn-default">搜索</button>
    </form>
    <div class="panel panel-default">
      <div class="panel-heading clearfix">
        注册用户列表
      </div>
      <div class="panel-body">
        <table class="table table-bordered table-striped">
          <thead>
          <tr>
            <th scope="col">UID</th>
            <th scope="col">头像</th>
            <th scope="col">手机</th>
            <th scope="col">地区</th>
            <th scope="col">余额</th>
            <th scope="col">累计收入</th>
            <th scope="col">邀请人数</th>
            <th scope="col">邀请收入</th>
            <th scope="col">注册日期</th>
            <th scope="col">师傅UID</th>
            <th scope="col">封禁状态</th>
            <th scope="col">封禁原因</th>
            <th scope="col">冻结状态</th>
            <th scope="col">IP</th>
            <th scope="col">管理</th>
          </tr>
          </thead>
          <tbody>
       <?php foreach ($rowsets as $id => $row):?>
          <tr>
            <td><?php echo $row['uid']?></td>
            <td><img style="width: 52px" src="<?php echo $row['avatar']?>" /><?php if(!empty($row['nickname'])):?><b>昵称：<?php echo $row['nickname']?></b><?php endif;?></td>
            <td><?php echo $row['mobile']?></td>
            <td><?php echo $row['address']?></td>
            <td><?php echo $row['balance']?></td>
            <td><?php echo $row['add_up']?></td>
            <td><?php echo $row['invite_num']?></td>
            <td><?php echo $row['invite_add_up']?></td>
            <td><?php echo date("Y-m-d H:i", $row['regtime'])?></td>
            <td><a href="/manage/user/index/?uid=<?php echo $row['parent_id']?>"><?php if(!empty($row['parent_id'])){echo $row['parent_id'];}?></a></td>
            <td><?php if($row['ban'] == 1) : echo "<span style='color:red'>已封禁</span>"; else : echo "正常"; endif;?></td>
            <td><?php if(!empty($row['ban_memo']) ) : echo "<span style='color:red'>{$row['ban_memo']}</span>"; else : echo ""; endif;?></td>
            <td><?php if($row['frozen'] == 1) : echo "<span style='color:red'>已冻结</span>"; else : echo "正常"; endif;?></td>
            <td><?php echo $row['remote_ip']?></td>
            <td class="btnBox"><a class="btn btn-success btn-sm" href="/manage/user/edituser/?uid=<?php echo $row['uid']?>">编辑</a>
               <a class="btn btn-success btn-sm" href="/manage/user/applylist/?uid=<?php echo $row['uid']?>">任务记录</a>
               <a class="btn btn-success btn-sm" href="/manage/user/exchangelist/?uid=<?php echo $row['uid']?>">收支记录</a>
               <a class="btn btn-success btn-sm" href="/manage/user/invitelist/?invite_uid=<?php echo $row['uid']?>">邀请记录</a>
               <?php if($row['ban'] == 1):?>
               <a class="btn btn-danger btn-sm" onclick="unblock('<?php echo $row['uid']?>');">解封</a>
              <?php else:?>
              <a class="btn btn-danger btn-sm" style="color: #fff" onclick="blockUser('<?php echo $row['uid']?>');">封禁用户</a>
              <?php endif;?>
            <?php if($row['frozen'] == 1):?>
              <a class="btn btn-danger btn-sm" style="color: #fff" onclick="unFrozen('<?php echo $row['uid']?>');">解冻</a>
            <?php else:?>
              <a class="btn btn-danger btn-sm" style="color: #fff" onclick="frozenUser('<?php echo $row['uid']?>');">冻结</a>
            <?php endif;?>
            </td>
          </tr>
          <?php endforeach;?>
          </tbody>
      </table>
        <?php $pager->render();?>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
  $(function () {
    $("#from").datetimepicker({format:"Y-m-d H:i:00"});
    $("#to").datetimepicker({format:"Y-m-d H:59:59"});
    $(".tip_close").click(function(event) {
      $("#tip_bg").hide();
      $("#frozen_bg").hide();
    });
  })
function blockUser(uid) {
    // 取消form表单提交
   var ans =  confirm('请注意：封禁之后账号余额不清零且可找回！');
   if(ans){
      var memo = prompt("封禁原因:")
      window.location.href="/manage/user/banuser?uid="+uid+"&memo="+memo
   }
}
function frozenUser(uid) {
  var memo = prompt("冻结原因:")
  window.location.href="/manage/user/frozenuser?uid="+uid+"&memo="+memo
}
function unblock(uid) {
  var ans =  confirm('确定要解封此用户');
  if(ans){
    var memo = prompt("封禁原因:")
    window.location.href='/manage/user/unbanuser/?uid='+uid
  }
}
function unFrozen(uid) {
	if(confirm("确定要解冻此用户？")) {
		window.location.href= '/manage/user/unFrozenUser/?uid='+uid ;
	}
	else {
		return false;
	}
}
</script>